package com.ruoyi.models.controller.cost;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.cost.domain.CostRechargeInfo;
import com.ruoyi.cost.service.ICostRechargeInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

/**
 * 充值记录Controller
 * 
 * @author zomcx
 * @date 2025-06-12
 */
@RestController
@RequestMapping("/cost/rechargeInfo")
@Tag(name = "【充值记录】管理")
public class CostRechargeInfoController extends BaseController
{
    @Autowired
    private ICostRechargeInfoService costRechargeInfoService;

    /**
     * 查询充值记录列表
     */
    @Operation(summary = "查询充值记录列表")
    @PreAuthorize("@ss.hasPermi('cost:rechargeInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(CostRechargeInfo costRechargeInfo)
    {
        startPage();
        List<CostRechargeInfo> list = costRechargeInfoService.selectCostRechargeInfoList(costRechargeInfo);
        return getDataTable(list);
    }

    /**
     * 导出充值记录列表
     */
    @Operation(summary = "导出充值记录列表")
    @PreAuthorize("@ss.hasPermi('cost:rechargeInfo:export')")
    @Log(title = "充值记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CostRechargeInfo costRechargeInfo)
    {
        List<CostRechargeInfo> list = costRechargeInfoService.selectCostRechargeInfoList(costRechargeInfo);
        ExcelUtil<CostRechargeInfo> util = new ExcelUtil<CostRechargeInfo>(CostRechargeInfo.class);
        util.exportExcel(response, list, "充值记录数据");
    }

    /**
     * 获取充值记录详细信息
     */
    @Operation(summary = "获取充值记录详细信息")
    @PreAuthorize("@ss.hasPermi('cost:rechargeInfo:query')")
    @GetMapping(value = "/{costRechargeId}")
    public AjaxResult getInfo(@PathVariable("costRechargeId") Long costRechargeId)
    {
        return success(costRechargeInfoService.selectCostRechargeInfoByCostRechargeId(costRechargeId));
    }

    /**
     * 新增充值记录
     */
    @Operation(summary = "新增充值记录")
    @PreAuthorize("@ss.hasPermi('cost:rechargeInfo:add')")
    @Log(title = "充值记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CostRechargeInfo costRechargeInfo)
    {
        return toAjax(costRechargeInfoService.insertCostRechargeInfo(costRechargeInfo));
    }

    /**
     * 修改充值记录
     */
    @Operation(summary = "修改充值记录")
    @PreAuthorize("@ss.hasPermi('cost:rechargeInfo:edit')")
    @Log(title = "充值记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CostRechargeInfo costRechargeInfo)
    {
        return toAjax(costRechargeInfoService.updateCostRechargeInfo(costRechargeInfo));
    }

    /**
     * 删除充值记录
     */
    @Operation(summary = "删除充值记录")
    @PreAuthorize("@ss.hasPermi('cost:rechargeInfo:remove')")
    @Log(title = "充值记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{costRechargeIds}")
    public AjaxResult remove(@PathVariable( name = "costRechargeIds" ) Long[] costRechargeIds) 
    {
        return toAjax(costRechargeInfoService.deleteCostRechargeInfoByCostRechargeIds(costRechargeIds));
    }
}
